package com.anti.modular.owner.ownerleaseroom.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.owner.ownerleaseroom.param.OwnerLeaseRoomParam;
import com.anti.modular.owner.ownerleaseroom.service.OwnerLeaseRoomService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 業主房間關係表控制器
 *
 * @author anti
 * @date 2021-05-20 14:28:47
 */
@RestController
@RequestMapping("ownerLeaseRoom")
public class OwnerLeaseRoomController {

    @Resource
    private OwnerLeaseRoomService ownerLeaseRoomService;

    /**
     * 查询業主房間關係表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, OwnerLeaseRoomParam ownerLeaseRoomParam) {
        return Result.data(ownerLeaseRoomService.page(pageParam,ownerLeaseRoomParam));
    }

    /**
     * 添加業主房間關係表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @PostMapping("add")
    @BusinessLog(title = "業主房間關係表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(OwnerLeaseRoomParam.add.class) OwnerLeaseRoomParam ownerLeaseRoomParam) {
            ownerLeaseRoomService.add(ownerLeaseRoomParam);
        return Result.success("新增成功");
    }

    /**
     * 删除業主房間關係表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @PostMapping("delete")
    @BusinessLog(title = "業主房間關係表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(OwnerLeaseRoomParam.delete.class) OwnerLeaseRoomParam ownerLeaseRoomParam) {
            ownerLeaseRoomService.delete(ownerLeaseRoomParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑業主房間關係表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @PostMapping("edit")
    @BusinessLog(title = "業主房間關係表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(OwnerLeaseRoomParam.edit.class) OwnerLeaseRoomParam ownerLeaseRoomParam) {
            ownerLeaseRoomService.edit(ownerLeaseRoomParam);
        return Result.success("修改成功");
    }

    /**
     * 查看業主房間關係表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @GetMapping("detail")
    public Result detail(@Validated(OwnerLeaseRoomParam.detail.class) OwnerLeaseRoomParam ownerLeaseRoomParam) {
        return Result.data(ownerLeaseRoomService.detail(ownerLeaseRoomParam));
    }

    /**
     * 業主房間關係表列表
     *
     * @author anti
     * @date 2021-05-20 14:28:47
     */
    @GetMapping("list")
    public Result list(OwnerLeaseRoomParam ownerLeaseRoomParam) {
        return Result.data(ownerLeaseRoomService.list(ownerLeaseRoomParam));
    }

}
